<template>
  <div class="app-container">

    <div>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane label="进行中" name="first">
          <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="100px">
            <el-form-item label="活动ID" prop="iaNumber">
              <el-input v-model="queryParams.iaNumber" placeholder="请输入活动id" />
            </el-form-item>
            <el-form-item label="活动名称" prop="iaName">
              <el-input v-model="queryParams.iaName" placeholder="请输入活动名称" />
            </el-form-item>
            <el-form-item label="任务状态" prop="bsStatus">
              <el-select v-model="queryParams.bsStatus" placeholder="请选择">
                <el-option v-for="item in [
                  { value: '0', label: '未开始' },
                  { value: '1', label: '进行中' },
                ]" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="handleQuery">查询</el-button>
              <el-button @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
          <span style="color: #107ce5;display: inline-block;cursor: pointer;" class="mb10" @click="toReport">[报告管理流程说明]</span>

        </el-tab-pane>
        <el-tab-pane label="已完成" name="second">
          <el-form :model="queryParams" ref="queryRef1" :inline="true" label-width="100px">
            <el-form-item label="活动ID" prop="iaNumber">
              <el-input v-model="queryParams.iaNumber" placeholder="请输入活动id" />
            </el-form-item>
            <el-form-item label="活动名称" prop="iaNumber">
              <el-input v-model="queryParams.iaName" placeholder="请输入活动名称" />
            </el-form-item>



            <el-form-item label="任务名称" prop="content">
              <el-select v-model="queryParams.content" placeholder="请选择">
                <el-option v-for="item in [
                  { value: '地震危险性评估', label: '地震危险性评估' },
                  { value: '房屋地震灾害风险评估', label: '房屋地震灾害风险评估' },
                  { value: '次生灾害隐患评估', label: '次生灾害隐患评估' },
                  { value: '伤亡及需紧急安置人员评估', label: '伤亡及需紧急安置人员评估' },
                  { value: '需紧急安置人员评估', label: '需紧急安置人员评估' },
                  { value: '重点场所风险评估', label: '重点场所风险评估' },
                ]" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="handleQuery1">查询</el-button>
              <el-button @click="resetQuery1">重置</el-button>
            </el-form-item>
          </el-form>

        </el-tab-pane>
      </el-tabs>
      <el-table v-loading="loading" border :data="getData" @selection-change="handleSelectionChange" class="table"
        :span-method="objectSpanMethod">
        <!--<el-table-column type="selection" width="55" align="center" />-->
        <el-table-column label="活动ID" align="center" prop="iaNumber" />
        <el-table-column label="活动名称" align="center" prop="iaNumber">
          <template #default="scope">
            <el-button type="text" @click="updateEnter(scope.row)">{{
              scope.row.iaName
            }}</el-button>
          </template>
        </el-table-column>
        <!--<el-table-column label="活动名称" align="center" prop="iaName" />-->
        <el-table-column label="任务名称" align="center" prop="content" width="250" />
        <el-table-column label="业务人员" align="center" prop="iaNumber">
          <template #default="scope">
            {{ scope.row.ywrys }}
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="iaNumber">
          <template #default="scope">
            {{ scope.row.iaCjr }}
          </template>
        </el-table-column>
        <el-table-column label="任务状态" align="center" prop="bsStatus">
          <template #default="scope">
            <span v-if="scope.row.bsStatus == '0'">未开始</span>
            <span v-if="scope.row.bsStatus == '1'">进行中</span>
            <span v-if="scope.row.bsStatus == '2'">已完成</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button type="text" @click="handleEnter(scope.row)">进入</el-button>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" prop="sign" v-if="activeName=='first'">
          <template #default="scope">
            <el-button type="text" @click="openReportManage(scope.row)">报告管理</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="total"  v-show="total > 0" v-model:page="queryParams.page" v-model:limit="queryParams.rows"
        @pagination="getListData" />
      <el-dialog :title="title" v-model="open" width="850px" append-to-body @close="closeDialog">
        <el-form ref="singleRef" :model="form" :rules="rules" label-width="120px">
          <h2 style="text-align: center; color: #0e76d7">
            重大活动安保事件管理
          </h2>
          <el-row>
            <el-col :span="12">
              <el-form-item label="活动ID" prop="iaNumber">
                <el-input v-model="form.iaNumber" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="活动名称" prop="iaNumber">
                <el-input v-model="form.iaName" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="活动分类" prop="hdlb">
                <el-select v-model="form.hdlb" placeholder="请选择" style="width:100%" disabled>
                  <el-option v-for="item in [{label:'国家级',value:'0'},{label:'省级',value:'1'}]" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <el-form-item label="省" prop="provinceId">
                <el-select v-model="form.provinceId" placeholder="请选择" @change="chooseFormProvince" style="width: 100%;"
                  disabled>
                  <el-option v-for="item in provinceFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="市" prop="cityId">
                <el-select v-model="form.cityId" placeholder="请选择" @change="chooseFormCity" style="width: 100%;" disabled>
                  <el-option v-for="item in cityFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="区/县" prop="countiesId">
                <el-select v-model="form.countiesId" placeholder="请选择" style="width: 100%;" @change="chooseFormArea"
                  disabled>
                  <el-option v-for="item in areaFormData" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="行政代码" prop="iaCode">
                <el-input v-model="form.iaCode" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="安保开始时间" prop="iaStartingTime">
                <el-date-picker value-format="YYYY-MM-DD" v-model="form.iaStartingTime" type="date" placeholder="开始时间"
                  style="width: 100%;" clearable disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="安保结束时间" prop="iaFinshTime">
                <el-date-picker value-format="YYYY-MM-DD" v-model="form.iaFinshTime" type="date" placeholder="结束时间"
                  style="width: 100%;" clearable disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-dialog title="请输入" v-model="iSZdmb" width="300px" append-to-body>
              <el-row style="margin: 20px 0;">
                <el-col :span="24">
                  <el-input v-model="form.iaZdmb" type="text" placeholder="请输入" />
                </el-col>
              </el-row>
              <template #footer>
                <div class="dialog-footer">
                  <el-button type="primary" @click="confirmZdmb" style="width: 20px;height: 30px;font-size: 14px;">确 定
                  </el-button>
                  <el-button @click="cancelZdmb" style="width: 20px;height: 30px;font-size: 14px;">取 消</el-button>
                </div>
              </template>
            </el-dialog>
            <el-col :span="24">
              <el-form-item label="重点目标" prop="iaZdmbs">
                <el-select v-model="form.iaZdmbs" multiple placeholder="请选择重点目标" style="width:100%" disabled>
                  <el-option v-for="item in optionZd" :key="item.ssId" :label="item.ssJzwmc" :value="item.ssId">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item label="活动简介" prop="iaHdjj">
                <el-input v-model="form.iaHdjj" type="textarea" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item label="文件通知">
                <file-upload :action="uploadFileUrl" ref="fileUpload" v-model="form.fileList" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <el-form-item>
                <el-button type="primary" @click="taskFg">任务分工</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-dialog title="任务分工" v-model="openFg" width="800px" top="200px" append-to-body>
            <p></p>
            <el-row>
              <el-col :span="6" class="tab-title">
                监测预报组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="form.jczDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="form.jczZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="form.jczCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="form.jczZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="form.jczGzcs" type="textarea" :rows="5" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                风险防范组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="form.fxzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="form.fxzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="form.fxzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="form.fxzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="form.fxzGzcs" type="textarea" :rows="5" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                应急准备组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="form.yjzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="form.yjzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="form.yjzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="form.yjzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="form.yjzGzcs" type="textarea" :rows="5" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                新闻宣传组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="form.xwzDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="form.xwzZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="form.xwzCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="form.xwzZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="form.xwzGzcs" type="textarea" :rows="5" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="6" class="tab-title">
                值守信息组
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="牵头单位" prop="">
                  <el-input v-model="form.zszDw" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="组长" prop="">
                  <el-input v-model="form.zszZz" type="text" disabled/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员" prop="">
                  <el-input v-model="form.zszCy" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主要职责" prop="">
                  <el-input v-model="form.zszZyzz" type="text" disabled/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="工作措施" prop="">
                  <el-input v-model="form.zszGzcs" type="textarea" :rows="5" disabled/>
                </el-form-item>
              </el-col>
            </el-row>

            <template #footer>
              <div class="dialog-footer">
                <!-- <el-button type="primary" @click="openFg = false">确 定</el-button> -->
                <el-button @click="openFg = false">取 消</el-button>
              </div>
            </template>
          </el-dialog>
          <el-row>
            <el-col :span="12">
              <el-form-item label="指导单位" prop="iaZddw">
                <!-- <el-input v-model="form.iaZddw" type="text" /> -->
                <el-cascader :options="iaZddwData" v-model="form.iaZddw" :props="{ checkStrictly: true }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaZddw" filterable disabled>
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaZddwYwry">

                <el-input v-model="form.iaZddwYwry" @click="openSelectUser(2, 'Zddw')" placeholder="请选择业务人员" readonly
                  style="width: 100%;" disabled />
              </el-form-item>
            </el-col>

            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaZddwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in zddwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaZddwYwryFg" label-width="100px">
                <el-select v-model="item.iaZddwYwryFg" placeholder="请选择" multiple disabled style="width: 100%;">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <!-- <el-button @click="delZddwYwry(index, item)" style="margin-left: 8px;" disabled>删除</el-button> -->
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="实施单位" prop="iaSsdw">
                <el-cascader :options="iaSsdwData" v-model="form.iaSsdw" :props="{ checkStrictly: true }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaSsdw" disabled>
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaSsdwYwry">
                <el-input v-model="form.iaSsdwYwry" @click="openSelectUser(2, 'Ssdw')" placeholder="请选择业务人员" readonly
                  style="width: 100%;" disabled />

              </el-form-item>
            </el-col>
            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaSsdwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in ssdwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaSsdwYwryFg" label-width="100px">
                <el-select v-model="item.iaSsdwYwryFg" placeholder="请选择" multiple disabled style="width: 100%;">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <!-- <el-button @click="delSsdwYwry(index, item)" style="margin-left: 8px;" disabled>删除</el-button> -->
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="协同单位" prop="iaXtdw">
                <el-cascader :options="iaXtdwData" v-model="form.iaXtdw" :props="{ checkStrictly: true }"
                  :show-all-levels="false" style="width: 100%;" @change="chooseIaXtdw" disabled>
                </el-cascader>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <el-form-item label="业务人员" prop="iaXtdwYwry">
                <el-input v-model="form.iaXtdwYwry" @click="openSelectUser(2, 'Xtdw')" placeholder="请选择业务人员" readonly
                  style="width: 100%;" disabled />
              </el-form-item>
            </el-col>
            <!--<el-col :span="3">
              <el-button
                :disabled="form.iaXtdwYwry == undefined"
                @click="addMembers"
                >添加
              </el-button>
            </el-col>-->
          </el-row>
          <el-row v-for="(item, index) in xtdwYwryList" :key="item.uuid">
            <el-col :span="8">
              <el-form-item label="人员姓名" prop="">
                <el-input v-model="item.realName" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="任务分工" prop="iaXtdwYwryFg" label-width="100px">
                <el-select v-model="item.iaXtdwYwryFg" placeholder="请选择" multiple disabled style="width: 100%;">
                  <el-option v-for="items in rwfgData" :key="items.value" :label="items.label" :value="items.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <!-- <el-button @click="delXtdwYwry(index, item)" style="margin-left: 8px;" disabled>删除</el-button> -->
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="初步审核" prop="iaCbsh">
                <el-input v-model="form.iaCbsh" type="text" disabled readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Cbsh')" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="部门审核" prop="iaBmsh">
                <el-input v-model="form.iaBmsh" type="text" disabled readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Bmsh')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="领导审核" prop="iaLdsh">
                <el-input v-model="form.iaLdsh" type="text" disabled readonly placeholder="请选择人员"
                  @click="openSelectUser(1, 'Ldsh')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="创建人" prop="iaCjr">
                <el-input v-model="form.iaCjr" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建人单位" prop="iaCjrDw">
                <el-input v-model="form.iaCjrDw" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="联系方式" prop="iaLxfs">
                <el-input v-model="form.iaLxfs" type="text" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="iaEmail">
                <el-input v-model="form.iaEmail" type="text" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="创建日期" prop="createTime2">
                <el-date-picker v-model="form.createTime2" type="date" value-format="YYYY-MM-DD" placeholder="请选择创建日期"
                  style="width: 100%;" disabled />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <!--<el-button type="primary" @click="submitForm">保存</el-button>
            <el-button type="primary" @click="closeForm">关闭</el-button>-->
          </div>
        </template>
      </el-dialog>
      <!-- 人员选择对话框 -->
      <el-dialog v-model="show" width="1200px" append-to-body>
        <template #title>
          人员选择<span v-show="isshow != 1">（多选）</span><span v-show="isshow == 1">（单选）</span>
        </template>
        <select-user ref="selectRef" :isshow="isshow" @getSelectList="getSelectList" />
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="ok">确 定</el-button>
            <el-button @click="cancelP">取 消</el-button>
          </div>
        </template>
      </el-dialog>
      <el-dialog title="历史安保事件" v-model="openCheck" width="850px" append-to-body>
        <el-form ref="singleRef" :model="form" :rules="rules" label-width="120px">
          <h2 style="text-align: center; color: #0e76d7">
            {{ checkForm.iaName }}
          </h2>
          <el-row>
            <el-col :span="12">
              <h3>活动ID:{{ checkForm.iaNumber }}</h3>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="12">
              <h3>省:{{ checkForm.iaProvince }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>市:{{ checkForm.iaCity }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>区/县:{{ checkForm.iaCounties }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>行政代码:{{ checkForm.iaCode }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>安保开始时间:{{ checkForm.iaStartingTime }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>安保结束时间:{{ checkForm.iaFinshTime }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>任务分工:{{ checkForm.iaAsses }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>重点目标:{{ checkForm.iaZdmb }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>活动简介:{{ checkForm.iaHdjj }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>文件通知:{{ checkForm.iaWjtz }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>指导单位:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>实施单位:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>协同单位:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>业务人员:</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>初步审核:{{ checkForm.iaCbsh }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>部门审核:{{ checkForm.iaBmsh }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>领导审核:{{ checkForm.iaLdsh }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>创建人:{{ checkForm.iaCjr }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>创建人单位:{{ checkForm.iaCjrDw }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <h3>联系方式:{{ checkForm.iaLxfs }}</h3>
            </el-col>
            <el-col :span="12">
              <h3>邮箱:{{ checkForm.iaEmail }}</h3>
            </el-col>
          </el-row>
          <el-row>
            <el-col>
              <h3>创建日期:{{ checkForm.createTime2 }}</h3>
            </el-col>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="toLeadForm">导入</el-button>
            <el-button type="primary" @click="closeForm1">关闭</el-button>
          </div>
        </template>
      </el-dialog>

      <!-- 报告管理 -->
      <!-- 上传进度展示 -->
      <el-dialog v-model="openReportCreate" title="正在生成报告" width="400px" :close-on-click-modal="false" append-to-body
        :show-close="false">
        <p></p>
        <div class="demo-progress">
          <el-progress :percentage="percentages" />
        </div>
        <div class="footer">
          <el-button plain @click="cancelUpload">取消生成</el-button>
        </div>
      </el-dialog>

      <el-dialog title="报告管理" v-model="openFile" width="500px" append-to-body> 
        <el-form ref="bgglRef" label-width="120px">
          <p class="dialogTitle">{{ titleName }}</p>
          <el-row>
            <el-col>
              <el-form-item label="报告名称" style="position: relative;">
                <span class="historyVersion" @click="historyVersion">历史版本查看</span>
                <file-upload :limit="1" ref="fileUploads" v-model="formFile.fileList"
                  :fileType='["doc", "docx", "ofd", "txt", "pdf"]' />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="fileSubmitForm">保 存</el-button>
            <el-button @click="openFile = false">取 消</el-button>
          </div>
        </template>
      </el-dialog>
      <el-dialog title="报告管理" v-model="openCreate" width="900px" append-to-body>
        <p class="dialogTitle">{{ titleName }}</p>
        <h3><span></span> 报告模板</h3>
        <el-select v-model="formData.reportModle" placeholder="请选择报告模板" style="width:50%">
          <el-option v-for="item in optionModle" :key="item.rtId" :label="item.rtName" :value="item.rtId">
          </el-option>
        </el-select>
        <h3><span></span> 系统生成</h3>
        <table class="tableport">
          <tr>
            <td class="reportTitle">报告名称</td>
            <td class="content">
              <template v-if="formData.reportName">
                <span @click="dowonReport({ attachId: formData.attachId })" style="color: #107ce5;cursor: pointer;" class="ellipsis">{{ formData.reportName }}</span>
              </template>
              <div class="button">
                <el-button type="primary" plain @click="createPort" v-if="!formData.reportName">生成报告
                </el-button>
                <el-button type="primary" plain @click="createPort" v-else>重新生成</el-button>
              </div>
            </td>
          </tr>
        </table>
        <h3><span></span> 报告上传</h3>
        <new-file-upload ref="fileUploadRef" :isShowTip="false" @uploadFile="uploadFile"
          :fileType='["docx"]'  :dataObj="{iaId:iaId,number:number}" :reportModle="formData.reportModle"/>
        <el-table v-loading="loading1" stripe :data="reportList" style="margin-top:20px" >
          <el-table-column label="报告名称" align="center" prop="name" width="350" show-overflow-tooltip>
            <template #default="scope">
              <span style="color: #107ce5;" @click="dowonReport(scope.row)">{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="提交状态" align="center" prop="status">
            <template #default="scope">
              <span v-if="scope.row.status == '0'">未提交</span>
              <span v-if="scope.row.status == '1'">已提交</span>
              <span v-if="scope.row.status == '2'">已退回</span>
            </template>
          </el-table-column>
          <el-table-column label="提交时间" align="center" prop="submitTime" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template #default="scope">
              <el-button type="text" @click="handleSubmit(scope.row)" v-if="scope.row.status=='2'">重新提交</el-button>
              <el-button type="text" @click="handleSubmit(scope.row)" v-if="scope.row.status=='0'">提交</el-button>
              <el-button type="text" @click="handleDeleteReport(scope.row)" v-if="scope.row.status == '0'">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <p style="color:#F56C6C"><b>提示：一经提交不可自行撤回，需联系活动管理员进行退回</b></p>
        <template #footer>
          <div class="dialog-footer">
            <el-button @click="openCreate = false">取 消</el-button>
          </div>
        </template>
      </el-dialog>
      <el-dialog title="查看历史版本" v-model="versionView" width="900px" append-to-body>
        <p></p>
        <p></p>
        <el-table :data="versionList" stripe>
          <el-table-column label="序号" align="center" prop="number" width="55" />
          <el-table-column label="报告类型" align="center" prop="type" />
          <el-table-column label="报告名称" align="center" prop="name" width="255" show-overflow-tooltip>
            <template #default="scope">
              <span @click="handleDown(scope.row)" style="color:#107ce5;cursor: pointer;">{{
                scope.row.name
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="上传人" align="center" prop="user" />
          <el-table-column label="上传时间" align="center" prop="time" width="160" />
        </el-table>
        <template #footer>
          <div class="dialog-footer">
            <el-button @click="versionView = false">关闭</el-button>
          </div>
        </template>
      </el-dialog>

      <!-- 添加备注 -->
      <el-dialog v-model="descripOpen" title="添加备注" width="400px" append-to-body>
        <p class="mt15"></p>
        <el-input v-model="describe" type="textarea" maxlength="500" show-word-limit :autosize="{ minRows: 5, maxRows: 5 }" placeholder="可添加补充说明（非必填）" />
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" size="small" @click="confirmDes">确定</el-button>
            <el-button @click="descripOpen = false" size="small">取消</el-button>
          </div>
        </template>
      </el-dialog>

    </div>
  </div>
</template>
  
<script setup>
import selectUser from "./selectUser";
import newFileUpload from '@/components/NewFileUpload'
import useUserStore from '@/store/modules/user';

import {
  getList,
  delList,
  saveList,
  updateList,
  serchList,
  getImport,
  getName,
  getDw,
  getZdmb,
  getActivityIdList,
  getAssessList,
  updateBigStatus
} from "@/api/business/activities";
import { getProvince, getChildArea, getDivisionCode } from "@/api/system/division";
import { dataMethod } from '@/utils/spanTable.js';
import {reportLists,submitCheck,delReport,submitReport,reportCreat,getRtTypeAll} from "@/api/assess/quantification.js"
import { useRoute } from "vue-router";
import { getPdf } from '@/api/system/getPdf.js';

const { proxy } = getCurrentInstance();
const rwfgData = ref([{ label: '地震环境及监测能力分析', value: '地震环境及监测能力分析' }, { label: '房屋地震灾害分析评估', value: '房屋地震灾害分析评估' }, { label: '地震灾害风险排查及建议', value: '地震灾害风险排查及建议' }])
const uploadFileUrl = ref(
  import.meta.env.VITE_APP_BASE_API + "/attachment/uploadFile"
); // 上传的图片服务器地址
const userStore = useUserStore();
const activeName = ref("first");
const openCheck = ref(false);
const iSZdmb = ref(false);
const serchData = ref([]);
const iaZddwData = ref([]);
const iaSsdwData = ref([]);
const iaXtdwData = ref([]);
const zddwYwryList = ref([]);
const zddwYwrys = ref([]);
const ssdwYwryList = ref([]);
const ssdwYwrys = ref([]);
const xtdwYwryList = ref([]);
const xtdwYwrys = ref([]);
const iaZdmbList = ref([]);
const loading = ref(true);
const serchloading = ref(false);
const isEditFile = ref(false);

const provinceData = ref([]); //省
const cityData = ref([]); //市
const areaData = ref([]); //区、县
const total = ref(0);
const title = ref(""); //标题
const open = ref(false); //新增dialog操作
const openFg = ref(false);
const getData = ref([]); //获取列表数组
const dateRange = ref([]);
const uniqueId = ref("");
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const control = ref(true);
const isshow = ref(undefined);
const isDw = ref(undefined);
const show = ref(false);
const time = ref();
const orgIdZddw = ref('');
const orgIdSsdw = ref('');
const orgIdXtdw = ref('');
const isShowTime = ref(true);
const isShowTab = ref(false);
const provinceFormData = ref([]);//表单省 
const cityFormData = ref([]);//表单市
const areaFormData = ref([]);//表单区、县

const spanObj = ref({});
const router = useRouter();
const route = useRoute();
const data = reactive({
  form: {},
  queryParams: {
    page: 1,
    rows: 20,
    iaNumber: null,
    iaName: null,
    iaActivityStatus: null,
    bsStatus: null,
  },
  serch: {
    iaName: null,
  },
  checkForm: {},
  rules: {
    iaZdmb: [{ required: true, message: "重点目标不能为空", trigger: "blur" }],
  },
});
const { queryParams, form, rules, serch, checkForm } = toRefs(data);

// 打开报告管理
const openCreate = ref(false);
const openFile = ref(false);
const openReportCreate = ref(false);
const percentages = ref(0);
const formData = ref({
  reportModle: undefined,
})
const optionModle = ref([]);
const versionList = ref([]);
const versionView = ref(false);
const titleName = ref("");
const iaId = ref(''); // 活动id
const number = ref();
function getReportModule(rtType){
  getRtTypeAll(rtType).then(res=>{
    optionModle.value = res.data?res.data:[];
  })
}
function openReportManage(row) { 
  row.value = row;
  formData.value = {};
  titleName.value = row.iaName;
  iaId.value = row.iaId;
  number.value = row.sign.split('@')[1]=='1'?'0':'1';
  getReportModule(number.value);
  loading1.value = true;
  reportLists({iaId:iaId.value,id:formData.value.reportModle,number:number.value}).then(res=>{
    // reportList.value = res.data?res.data:[];
    reportList.value = res.data.littleReports?res.data.littleReports:[];
    if(!res.data.reportHuiXian){
      formData.value.attachId = "";
    formData.value.reportName = "";
    }else{
      formData.value.attachId = res.data.reportHuiXian.attId;
      formData.value.reportName = res.data.reportHuiXian.attName;
    }
    loading1.value = false;
    openCreate.value = true;
  }).catch(()=>{loading1.value = false;openCreate.value = false;})
}
// 生成
function createPort() {
  if(!formData.value.reportModle||formData.value.reportModle==''){
    proxy.$modal.msgWarning('请先选择报告模版！！')
  }else{
    percentages.value = 0;
    openReportCreate.value = true;
    let startTime = setInterval(() => {
      if (percentages.value < 50) {
          percentages.value += 5;
      }
      if (percentages.value == 50) {
          clearInterval(startTime);
          let conductTime = setInterval(() => {
              if (percentages.value == 95) {
                  clearInterval(conductTime);
              }
              if (percentages.value < 96) {
                  percentages.value += 2;
              }
          }, 100)
      }
    }, 100)
    reportCreat({iaId:iaId.value,id:formData.value.reportModle,number:number.value},cancelFunc).then(res => {
      percentages.value = 100;
      openReportCreate.value = false;
      proxy.$modal.msgSuccess("生成成功");
      formData.value.reportName = res.data[0].attachName;
      formData.value.attachId = res.data[0].attachId;
      clearInterval(startTime);
    }).catch(err => {
      openReportCreate.value = false;
      if (err.message !== '取消成功') {
          cancelFunc.c = null
      }
    })
  }  
}
// 取消生成
let cancelFunc = {}
function cancelUpload() {
    if (typeof cancelFunc.c === "function") {
        cancelFunc.c('取消成功')
    }
    openCreate.value = false;
    percentages.value = 0;
}
// 查看历史版本
function historyVersion() {
  getVersion({ iaId: route.query.id, }).then(res => {
    versionList.value = res.data ? res.data : [];
    if (versionList.value.length > 0) {
      versionList.value.forEach((item, index) => {
        item.number = index + 1
      })
    }
    versionView.value = true;
  })
}

// 上传报告成功 
function uploadFile(value) {
  // console.log(value, 'shangchuan');
  getReportList();
}
// 提交报告
const descripOpen = ref(false);
const describe = ref('') // 备注
const reportId = ref('') // 报告id
function handleSubmit(row) {
  reportId.value = row.id
  // 提交检查
  submitCheck({iaId:iaId.value,id:formData.value.reportModle,number:number.value}).then(res=>{
    if(res.data){
      descripOpen.value = true;
    }else{
      proxy.$modal.msgWarning('已有提交报告！！！')
    }
  })
}
// 提交报告
function confirmDes(){
  submitReport({description:describe.value,id:reportId.value}).then(res=>{
    descripOpen.value = false;
    proxy.$modal.msgSuccess('提交成功');
    getReportList();
  })
}
// 获取报告列表
const reportList = ref([]);
const loading1 = ref(0);
function getReportList() {
  loading1.value = true;
  reportLists({iaId:iaId.value,id:formData.value.reportModle,number:number.value}).then(res=>{
    // reportList.value = res.data?res.data:[];
    reportList.value = res.data.littleReports?res.data.littleReports:[];
    if(!res.data.reportHuiXian){
      formData.value.attachId = "";
    formData.value.reportName = "";
    }else{
      formData.value.attachId = res.data.reportHuiXian.attId;
      formData.value.reportName = res.data.reportHuiXian.attName;
    }
    loading1.value = false;
  }).catch(()=>{loading1.value = false;})
}
// 下载报告
function dowonReport(row){
  location.href = import.meta.env.VITE_APP_BASE_API + "/attachment/downLoadFile?attachId=" + encodeURIComponent(row.attachId);
}
// 删除报告
function handleDeleteReport(row){
  proxy.$modal
    .confirm("确定删除该报告？")
    .then(function () {
      return delReport(row.id);
    })
    .then(() => {
      getReportList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => { });
}

// 合并列
function objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  //判断合并列
  const _row = spanObj.value[column.property] ? spanObj.value[column.property][rowIndex] : 1;
  const _col = _row > 0 ? 1 : 0;
  return {
    rowspan: _row,
    colspan: _col,
  }
}


function editProvinceFormData(provinceId, cityId) {
  getProvince().then(response => {
    provinceFormData.value = response.data;
  });
  getChildArea(provinceId).then(response => {
    cityFormData.value = response.data;
  });
  getChildArea(cityId).then(response => {
    areaFormData.value = response.data;
  });
}

function chooseFormProvince(value) {
  form.value.cityId = null;
  form.value.countiesId = null;
  cityFormData.value = [];
  areaFormData.value = [];
  getChildArea(value).then(response => {
    cityFormData.value = response.data;
  });
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });

}

function chooseProvince(value) {
  console.log(value);
  queryParams.value.cityId = null;
  queryParams.value.countiesId = null;
  cityData.value = [];
  areaData.value = [];
  getChildArea(value).then(response => {
    cityData.value = response.data;
  });
}

function chooseCity(value) {
  queryParams.value.countiesId = null;
  areaData.value = [];
  getChildArea(value).then((response) => {
    areaData.value = response.data;
  });
}

function chooseFormCity(value) {
  form.value.countiesId = null;
  areaFormData.value = [];
  getChildArea(value).then(response => {
    areaFormData.value = response.data;
  });
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });
}
function chooseFormArea(value) {
  getDivisionCode(value).then(response => {
    form.value.iaCode = response.data;
  });
}

/** 获取省列表 */
function getProvinceData() {
  getProvince().then((response) => {
    provinceData.value = response.data;
    provinceFormData.value = response.data;
  });
}

/** 获取单位 */
function getDwData() {
  getDw().then((response) => {
    response.data.forEach((item)=>{
      if(item.label=='中国地震灾害防御中心'){
        item.children = [];
      }
    })    
    iaZddwData.value = response.data;
    iaSsdwData.value = response.data;
    iaXtdwData.value = response.data;
  });
}

onActivated(() => {
  const time = route.query.t;
  if (time != null && time != uniqueId.value) {
    uniqueId.value = time;
    queryParams.value.page = Number(route.query.page);
    proxy.resetForm("queryRef");
    getListData();
  }
});

// 获取列表
function getListData() {
  loading.value = true;
  queryParams.value.iaActivityStatus = "0"
  getAssessList(queryParams.value).then((res) => {
    loading.value = false;
    const start = (queryParams.value.page - 1) * queryParams.value.rows;
    const end = res.data.rows.length > queryParams.value.page ? res.data.rows.length : queryParams.value.page * queryParams.value.rows;
    getData.value = res.data.rows.slice(start, end);
    spanObj.value = dataMethod(getData.value, ['iaNumber', 'iaName','sign']);
    let totals = 0;
    totals = spanObj.value.iaNumber.filter(item => item != 0).length;
    total.value = Number(totals);
  });
}

// 获取列表
function getListData1() {
  loading.value = true;
  queryParams.value.iaActivityStatus = "1"
  getAssessList(queryParams.value).then((res) => {
    loading.value = false;
    const start = (queryParams.value.page - 1) * queryParams.value.rows;
    const end = res.data.rows.length > queryParams.value.page ? res.data.rows.length : queryParams.value.page * queryParams.value.rows;
    getData.value = res.data.rows.slice(start, end);
    spanObj.value = dataMethod(getData.value, ['iaNumber', 'iaName','sign']);
    let totals = 0;
    totals = spanObj.value.iaNumber.filter(item => item != 0).length;
    total.value = Number(totals);
  });
}

//获取当前时间
function getNowFormatDate() {
  let date = new Date(),
    seperator1 = '-', //格式分隔符
    year = date.getFullYear(), //获取完整的年份(4位)
    month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
    strDate = date.getDate() // 获取当前日(1-31)
  if (month >= 1 && month <= 9) month = '0' + month // 如果月份是个位数，在前面补0
  if (strDate >= 0 && strDate <= 9) strDate = '0' + strDate // 如果日是个位数，在前面补0

  let currentdate = year + seperator1 + month + seperator1 + strDate
  return currentdate
}

//获取活动ID
function getImportantActivityId() {
  getActivityIdList().then((res) => {
    form.value.iaNumber = res.data.nextSerialNo;
  });
}

function closeForm1() {
  openCheck.value = false;
  // reset();
}

//关闭表单操作
function closeForm() {
  open.value = false;
  // isShowTab.value = false;
}
// 查看报告流程
function toReport(){
	const url = router.resolve({
	   path: '/report',
     query:{
      type:'0',
     }
	 });
	// 打开新窗口
	window.open(url.href);
}
// 查询
function handleQuery() {
  queryParams.page = 1;
  getListData();
}
// 查询
function handleQuery1() {
  queryParams.page = 1;
  getListData1();
}
// 重置
function resetQuery() {
  dateRange.value = [];
  proxy.resetForm("queryRef");
  getListData();
}

function resetQuery1() {
  dateRange.value = [];
  queryParams.value.iaStatus = null;
  proxy.resetForm("queryRef1");
  getListData1();
}

//复选框操作
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.iaId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

// 删除
function delData() {
  proxy.$modal
    .confirm(
      "该操作会删除选中的重大安保服务活动的所有数据（包含活动信息、评估结果和负责对策信息结果），是否确定删除？"
    )
    .then(function () {
      return delList(ids.value.join(","));
    })
    .then(() => {
      getListData();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => { });
}

//修改操作
const optionZd = ref([]);//重点目标
function updateEnter(row) {
  console.log(row);
  reset();
  const id = row.iaId
  zddwYwryList.value = []
  ssdwYwryList.value = []
  xtdwYwryList.value = []
  isEditFile.value = false;
  getImport(id).then(response => {
    form.value = response.data.importantActivity;
    form.value.fileList = response.data.list;
    form.value.iaZdmbs = form.value.iaZdmb.split(',');
    editProvinceFormData(response.data.importantActivity.provinceId, response.data.importantActivity.cityId);
    const query = { province: form.value.provinceId, city: form.value.cityId, county: form.value.countiesId }
    getZdmb(query).then(res => {
      optionZd.value = res.data;
  })

    orgIdZddw.value = response.data.importantActivity.iaZddw;
    orgIdSsdw.value = response.data.importantActivity.iaSsdw;
    orgIdXtdw.value = response.data.importantActivity.iaXtdw;
    if (response.data.importantActivity.zddwYwrys != null && response.data.importantActivity.zddwYwrys != '') {
      response.data.importantActivity.zddwYwrys.forEach((item) => {
        zddwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaZddwYwryFg": item.duties
        });
      });
    }
    if (response.data.importantActivity.ssdwYwrys != null && response.data.importantActivity.ssdwYwrys != '') {
      response.data.importantActivity.ssdwYwrys.forEach((item) => {
        ssdwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaSsdwYwryFg": item.duties
        });
      });
    }
    if (response.data.importantActivity.xtdwYwrys != null && response.data.importantActivity.xtdwYwrys != '') {
      response.data.importantActivity.xtdwYwrys.forEach((item) => {
        xtdwYwryList.value.push({
          "uuid": item.id,
          "realName": item.name,
          "iaXtdwYwryFg": item.duties
        });
      });
    }

    open.value = true;
    title.value = "修改重大安保事件管理";
  });
  //open.value = true;
  //isShowTime.value = true;
  //title.value = "修改重大安保事件管理";
  //form.value.iaId = row.iaId;
  //form.value.iaNumber = row.iaNumber;
  //form.value.iaName = row.iaName;
  //
  //form.value.provinceId = row.iaProvince;
  //form.value.cityId = row.iaCity;
  //form.value.countiesId = row.iaCounties;
  //
  //form.value.iaCode = row.iaCode;
  //form.value.iaStartingTime = row.iaStartingTime;
  //form.value.iaFinshTime = row.iaFinshTime;
  //form.value.iaAsses = row.iaAsses;
  //form.value.iaZdmb = row.iaZdmb;
  //form.value.iaWjtz = row.iaWjtz;
  //form.value.iaHdjj = row.iaHdjj;
  //form.value.iaZddw = row.iaZddw;
  //form.value.iaZddwYwry = row.iaZddwYwry;
  //form.value.iaSsdw = row.iaSsdw;
  //form.value.iaSsdwYwry = row.iaSsdwYwry;
  //form.value.iaXtdw = row.iaXtdw;
  //form.value.iaXtdwYwry = row.iaXtdwYwry;
  //form.value.iaCbsh = row.iaCbsh;
  //form.value.iaBmsh = row.iaBmsh;
  //form.value.iaLdsh = row.iaLdsh;
  //form.value.iaCjr = row.iaCjr;
  //form.value.iaCjrDw = row.iaCjrDw;
  //form.value.iaLxfs = row.iaLxfs;
  //form.value.iaEmail = row.iaEmail;
  //form.value.createTime2 = row.createTime2;
}

function transformYwry() {
  zddwYwryList.value.forEach((item) => {
    zddwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaZddwYwryFg
    });
  });
  ssdwYwryList.value.forEach((item) => {
    ssdwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaSsdwYwryFg
    });
  });
  xtdwYwryList.value.forEach((item) => {
    xtdwYwrys.value.push({
      "id": item.uuid,
      "name": item.realName,
      "duties": item.iaXtdwYwryFg
    });
  });

}


//保存
function submitForm() {
  transformYwry()
  console.log(zddwYwryList.value);
  console.log(JSON.parse(JSON.stringify(zddwYwrys.value)));
  // console.log(proxy.$refs["fileUpload"].fileList);
  const fileList = JSON.parse(
    JSON.stringify(proxy.$refs["fileUpload"].fileList)
  );
  // console.log(fileList);
  const attachIds = [];
  for (var i = 0; i < fileList.length; i++) {
    attachIds.push(fileList[i].attachId);
  }
  form.value.iaWjtz = attachIds.join(",");
  proxy.$refs["singleRef"].validate((vaild) => {
    if (!vaild) {
      return;
    }
    if (title.value != "修改重大安保事件管理") {
      saveList({
        iaNumber: form.value.iaNumber,
        iaName: form.value.iaName,
        provinceId: form.value.provinceId,
        cityId: form.value.cityId,
        countiesId: form.value.countiesId,
        iaCode: form.value.iaCode,
        iaStartingTime: getTime(form.value.iaStartingTime),
        iaFinshTime: getTime(form.value.iaFinshTime),
        zdmbs: form.value.iaZdmbs.split(','),
        iaWjtz: form.value.iaWjtz,

        iaHdjj: form.value.iaHdjj,

        iaZddw: form.value.iaZddw,
        zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

        iaSsdw: form.value.iaSsdw,
        ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

        iaXtdw: form.value.iaXtdw,
        xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

        iaAsses: form.value.iaAsses,
        //iaZdmb: form.value.iaZdmb,


        iaZddwYwry: form.value.iaZddwYwry,

        iaSsdwYwry: form.value.iaSsdwYwry,

        iaXtdwYwry: form.value.iaXtdwYwry,
        iaCbsh: form.value.iaCbsh,
        iaBmsh: form.value.iaBmsh,
        iaLdsh: form.value.iaLdsh,
        iaCjr: form.value.iaCjr,
        iaCjrDw: form.value.iaCjrDw,
        iaLxfs: form.value.iaLxfs,
        iaEmail: form.value.iaEmail,
      }).then((res) => {
        open.value = false;
        proxy.$modal.msgSuccess("新增成功");
        reset();
        getListData();
      });
    } else {
      updateList({
        iaId: form.value.iaId,
        iaNumber: form.value.iaNumber,
        iaName: form.value.iaName,
        provinceId: form.value.provinceId,
        cityId: form.value.cityId,
        countiesId: form.value.countiesId,
        iaCode: form.value.iaCode,
        iaStartingTime: getTime(form.value.iaStartingTime),
        iaFinshTime: getTime(form.value.iaFinshTime),
        zdmbs: form.value.iaZdmbs.split(','),
        iaWjtz: form.value.iaWjtz,

        iaHdjj: form.value.iaHdjj,

        iaZddw: form.value.iaZddw,
        zddwYwrys: JSON.parse(JSON.stringify(zddwYwrys.value)),

        iaSsdw: form.value.iaSsdw,
        ssdwYwrys: JSON.parse(JSON.stringify(ssdwYwrys.value)),

        iaXtdw: form.value.iaXtdw,
        xtdwYwrys: JSON.parse(JSON.stringify(xtdwYwrys.value)),

        iaAsses: form.value.iaAsses,
        //iaZdmb: form.value.iaZdmb,


        iaZddwYwry: form.value.iaZddwYwry,

        iaSsdwYwry: form.value.iaSsdwYwry,

        iaXtdwYwry: form.value.iaXtdwYwry,
        iaCbsh: form.value.iaCbsh,
        iaBmsh: form.value.iaBmsh,
        iaLdsh: form.value.iaLdsh,
        iaCjr: form.value.iaCjr,
        iaCjrDw: form.value.iaCjrDw,
        iaLxfs: form.value.iaLxfs,
        iaEmail: form.value.iaEmail,
        createTime2: form.value.createTime2,
      }).then((res) => {
        open.value = false;
        proxy.$modal.msgSuccess("修改成功");
        getListData();
      });
    }
  });
}

// 转换时间
function getTime(time) {
  const d = new Date(time);
  const newTime =
    d.getFullYear() +
    "-" +
    (d.getMonth() + 1) +
    "-" +
    d.getDate() +
    " " +
    d.getHours() +
    ":" +
    d.getMinutes() +
    ":" +
    d.getSeconds();
  return newTime;
}

// 打开人员弹窗
function openSelectUser(num, dw) {
  console.log(dw)
  time.value = new Date().getTime();
  isshow.value = num;
  isDw.value = dw;
  show.value = true;
  if (dw == "Zddw") {
    nextTick(() => {
      proxy.$refs["selectRef"].reset();
      proxy.$refs["selectRef"].getTreeselect(orgIdZddw.value);
    });
  } else if (dw == "Ssdw") {
    nextTick(() => {
      proxy.$refs["selectRef"].reset();
      proxy.$refs["selectRef"].getTreeselect(orgIdSsdw.value);
    });
  } else if (dw == "Xtdw") {
    nextTick(() => {
      proxy.$refs["selectRef"].reset();
      proxy.$refs["selectRef"].getTreeselect(orgIdXtdw.value);
    });
  } else {
    nextTick(() => {
      proxy.$refs["selectRef"].reset();
      proxy.$refs["selectRef"].getAllTreeselect();
    });
  }

}

// 提交人员
function ok() {
  show.value = false;
  nextTick(() => {
    proxy.$refs["selectRef"].submit();
  });
}

/** 关闭人员弹窗 */
function cancelP() {
  show.value = false;
  proxy.$refs["selectRef"].reset();
}

// 获取人名
function getGroupName(data) {
  let arr = [];
  data.forEach((item) => {
    arr.push(item.realName);
  });
  return arr.join(",");
}

// 选择的数据
function getSelectList(val) {
  let value = JSON.parse(JSON.stringify(val));
  console.log(value);
  switch (isDw.value) {
    case "Zddw":
      form.value.iaZddwYwry = getGroupName(value);
      zddwYwryList.value = value;

      break;
    case "Ssdw":
      form.value.iaSsdwYwry = getGroupName(value);
      ssdwYwryList.value = value;
      break;
    case "Xtdw":
      form.value.iaXtdwYwry = getGroupName(value);
      xtdwYwryList.value = value;
      break;
    case "Cbsh":
      form.value.iaCbsh = value[0].realName;

      break;
    case "Bmsh":
      form.value.iaBmsh = value[0].realName;

      break;
    case "Ldsh":
      form.value.iaLdsh = value[0].realName;

      break;
    default:
      break;
  }
}

//关闭dialog
function closeDialog() {
  open.value = false;
  // isShowTab.value = false;
  reset();
}

//
function addZdmb() {
  iSZdmb.value = true;
}

//toLeadForm导入
function toLeadForm() {
  form.value = checkForm.value
  editProvinceFormData(checkForm.value.provinceId, checkForm.value.cityId)
  openCheck.value = false;
}

//表单重置
function reset() {
  form.value = {};
  serch.value = {};
  iaZdmbList.value = [];
  proxy.resetForm("singleRef");
}

//进入
function handleEnter(row) {
  if (row.bsStatus == '0') {
    updateBigStatus({ bbId: row.bbId, content: row.content }).then(res => {
      console.log('改变状态');
    })
  }
  // router.push('/incident')
  if (row.content == "地震危险性评估") {
    router.push({
      path: "/assess/earthquake",
      query: {
        id: row.iaId
      }
    })
  } else if (row.content == "房屋地震灾害风险评估") {
    router.push({
      path: "/assess/house",
      query: {
        id: row.iaId
      }
    })
  } else if (row.content == "伤亡及需紧急安置人员评估") {
    router.push({
      path: "/assess/population",
      query: {
        id: row.iaId
      }
    })
  } else if (row.content == "需紧急安置人员") {
    router.push({
      path: "/assess/urgency",
      query: {
        id: row.iaId
      }
    })
  } else if (row.content == "重点场所风险评估") {
    router.push({
      path: "/assess/emphasis",
      query: {
        id: row.iaId
      }
    })
  }

}
// 获取人名
function getZdmbName(data) {
  let arr = [];
  data.forEach((item) => {
    arr.push(item.iaZdmbItem);
  });
  return arr.join(",");
}

function confirmZdmb() {
  //	getName({ ssJzwmc: form.value.iaZdmb }).then(res => {
  //  console.log(res);
  //  if(!res.data){
  //  	proxy.$modal
  //	    .confirm(
  //	      res.message
  //	    )    
  //	    .then(() => {
  //	      router.push({ path: "/activities/incident" });
  //	    })
  //	    .catch(() => {});
  //  }else{
  //  	iaZdmbList.value.push({
  //  		iaZdmbItem:form.value.iaZdmb
  //  	})
  //  	form.value.iaZdmbs = getZdmbName(iaZdmbList.value)
  //  }
  //  
  //  iSZdmb.value = false;
  //  form.value.iaZdmb = null;
  //});
  iaZdmbList.value.push({
    iaZdmbItem: form.value.iaZdmb
  })
  form.value.iaZdmbs = getZdmbName(iaZdmbList.value)
  iSZdmb.value = false;
  form.value.iaZdmb = null;
}

function cancelZdmb() {
  iSZdmb.value = false;
  form.value.iaZdmb = null;
}
//重点目标操作
function handleBlur() {
  // console.log(111);
  getName({ ssJzwmc: form.value.iaZdmb }).then((res) => {
    console.log(res);
  });
}

// 添加小组成员
function addMembers() {
  queryList.value.MemberList = indexData(form.value.MemberList);
}
//选择历史安保事件
function chooseIaName(value) {
  console.log(JSON.parse(JSON.stringify(value)))
  const iaId = JSON.parse(JSON.stringify(value))
  getImport(iaId).then(response => {
    checkForm.value = response.data;
    openCheck.value = true;

  });
}
//选择指导单位
function chooseIaZddw(value) {
  console.log(JSON.parse(JSON.stringify(value)))
  var orgIdZddwArr = JSON.parse(JSON.stringify(value))
  if (orgIdZddwArr.length == 1) {
    orgIdZddw.value = orgIdZddwArr[0]
    form.value.iaZddw = orgIdZddwArr[0]
  } else if (orgIdZddwArr.length == 2) {
    orgIdZddw.value = orgIdZddwArr[1]
    form.value.iaZddw = orgIdZddwArr[1]
  } else if (orgIdZddwArr.length == 3) {
    orgIdZddw.value = orgIdZddwArr[2]
    form.value.iaZddw = orgIdZddwArr[2]
  }
}
//选择实施单位
function chooseIaSsdw(value) {
  console.log(JSON.parse(JSON.stringify(value)))
  var orgIdSsdwArr = JSON.parse(JSON.stringify(value))
  if (orgIdSsdwArr.length == 1) {
    orgIdSsdw.value = orgIdSsdwArr[0]
    form.value.iaSsdw = orgIdSsdwArr[0]
  } else if (orgIdSsdwArr.length == 2) {
    orgIdSsdw.value = orgIdSsdwArr[1]
    form.value.iaSsdw = orgIdSsdwArr[1]
  } else if (orgIdSsdwArr.length == 3) {
    orgIdSsdw.value = orgIdSsdwArr[2]
    form.value.iaSsdw = orgIdSsdwArr[2]
  }
}
//选择协同单位
function chooseIaXtdw(value) {
  console.log(JSON.parse(JSON.stringify(value)))
  var orgIdXtdwArr = JSON.parse(JSON.stringify(value))
  if (orgIdXtdwArr.length == 1) {
    orgIdXtdw.value = orgIdXtdwArr[0]
    form.value.iaXtdw = orgIdXtdwArr[0]
  } else if (orgIdXtdwArr.length == 2) {
    orgIdXtdw.value = orgIdXtdwArr[1]
    form.value.iaXtdw = orgIdXtdwArr[1]
  } else if (orgIdXtdwArr.length == 3) {
    orgIdXtdw.value = orgIdXtdwArr[2]
    form.value.iaXtdw = orgIdXtdwArr[2]
  }
}

//删除指导单位
function delZddwYwry(index, item) {
  zddwYwryList.value.splice(index, 1);
  form.value.iaZddwYwry = getGroupName(zddwYwryList.value);
}
//删除实施单位
function delSsdwYwry(index, item) {
  ssdwYwryList.value.splice(index, 1);
  form.value.iaSsdwYwry = getGroupName(ssdwYwryList.value);
}
//删除协同单位
function delXtdwYwry(index, item) {
  xtdwYwryList.value.splice(index, 1);
  form.value.iaXtdwYwry = getGroupName(xtdwYwryList.value);
}
/*切换标签页*/
function handleClick(tab, event) {
  console.log(tab.props.name);
  proxy.resetForm("queryRef");
  proxy.resetForm("queryRef1");
  queryParams.value.page = 1;
  if (tab.props.name == "first") {

    getListData();
  } else {
    getListData1();
  }
}

function setTable(tableData) {
  let spanOneArr = [],
    spanTwoArr = [],
    spanThreeArr = [],
    spanFourArr = [],
    concatOne = 0,
    concatTwo = 0,
    concatThree = 0,
    concatFour = 0;
  tableData.forEach((item, index) => {
    if (index === 0) {
      spanOneArr.push(1);
      spanTwoArr.push(1);
      spanThreeArr.push(1);
      spanFourArr.push(1);
    } else {
      if (item.iaNumber === tableData[index - 1].iaNumber) {
        //第一列需合并相同内容的判断条件
        spanOneArr[concatOne] += 1;
        spanOneArr.push(0);
      } else {
        spanOneArr.push(1);
        concatOne = index;
      }

      if (item.iaName === tableData[index - 1].iaName) {
        //第二列和需合并相同内容的判断条件
        spanTwoArr[concatTwo] += 1;
        spanTwoArr.push(0);
      } else {
        spanTwoArr.push(1);
        concatTwo = index;
      }

      if (item.ywrys === tableData[index - 1].ywrys) {
        //第三列和需合并相同内容的判断条件
        spanThreeArr[concatThree] += 1;
        spanThreeArr.push(0);
      } else {
        spanThreeArr.push(1);
        concatThree = index;
      }

      if (item.iaCjr === tableData[index - 1].iaCjr) {
        //第三列和需合并相同内容的判断条件
        spanFourArr[concatFour] += 1;
        spanFourArr.push(0);
      } else {
        spanFourArr.push(1);
        concatFour = index;
      }
    }
  });
  return {
    one: spanOneArr,
    two: spanTwoArr,
    three: spanThreeArr,
    four: spanFourArr,
  };
}
//点击任务分工
function taskFg() {
  openFg.value = true;
}

getListData();
getProvinceData();
getDwData();
</script>

<style lang="scss" scoped>
.tabitem {
  list-style: none;
  height: 32px;
  line-height: 32px;
  text-align: left;
  margin-left: -40px;
  border: 1px solid;
}

.tabitem:hover {
  background-color: #107ce5;
  color: #ffff;
}

.navtab {
  width: 550px;
  /* margin-top: -23px; */
  position: absolute;
  height: 100%;
  margin-top: -45px;
  z-index: 1005;
  background-color: #fff;
}

.navwrap {
  font-size: 0.26rem;
  width: 100%;
  /* color: #c2c2c2; */
  background-color: #fff;
}

.input {
  width: 550px;
}

:deep(.el-table) td.el-table__cell {
  border-bottom: 1px solid #ebeef5 !important;
  border-right: 1px solid #ebeef5 !important;
}

.tableport {
  border-collapse: collapse;
  width: 100%;

  tr {
    height: 54px;

    td {
      border: 1px solid #000;

      &.reportTitle {
        text-align: center;
        width: 250px;
        font-weight: 700;
        color: 16px;
      }

      &.content {
        padding: 0px 20px;
        line-height: 54px;
        .ellipsis{
                    display: inline-block;
                    color: #107ce5;
                    cursor: pointer;
                    /* 单行文本溢出省略号 */
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    float: left;
                }
        .button {
          float: right;
          height: 54px;
          vertical-align: middle;
        }
      }
    }
  }

}

h3 {
  color: #333;
  height: 21px;
  font-size: 16px;
  line-height: 21px;
  display: flex;
  align-items: center;

  span {
    margin-right: 12px;
    display: inline-block;
    width: 3px;
    height: 16px;
    background: #333;
  }
}

.demo-progress .el-progress--line {
  margin: 40px 0;
  // margin-bottom: 15px;
  width: 350px;
}
.footer{
  text-align: center;
  padding-bottom: 20px;
}
</style>
  